package com.example.spring.activemq.jms.vo;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ExceptionBusiness extends ExceptionInfoType {
    private static final Logger log = LoggerFactory.getLogger(ExceptionBusiness.class);

    private ExceptionBusiness(String code, String msg) {
        super(code, msg);
    }

    public static ExceptionInfoType getIntance(EnumInfoType eit, String msg) {
        String msgTemp = eit.getMsg() + (StringUtils.isNotBlank(msg) ? "，具体原因：" + msg : "");
        return new ExceptionBusiness(eit.getCode(), msgTemp);
    }

    public static ExceptionInfoType getIntance(EnumInfoType eit) {
        return getIntance(eit, "");
    }

    public static ExceptionInfoType getIntance() {
        return getIntance(EnumResult.FAILED);
    }

    public static ExceptionInfoType getIntanceFmt(EnumInfoType eit, Object... arguments) {
        return new ExceptionBusiness(eit.getCode(), String.format(eit.getMsg(), arguments));
    }
}
